function u = util(c, util_type, gam)

if strcmp(util_type, 'quad') %%% Quadratic utility u(c) = c - 0.5*gam*c^2; 
    
    u = c - 0.5*gam*c.^2; 
    
elseif strcmp(util_type, 'crra')
    if gam == 1
        u = log(c); 
    else
        u = (c.^(1-gam)-1)./(1-gam); 
    end
else
    u = NaN; 
    
end

end